/*
 * @Author: Qimu
 * @Date: 2020-05-13 22:18:58
 * @LastEditors: Qimu
 * @LastEditTime: 2020-07-12 18:35:47
 * @Description: file content
 * @FilePath: \vue-admin-koa2\vue-admin\src\plugins\validate.js
 */

import utils from '@/plugins/utils';// 工具方法封装

const validate = {
  //登录验证
  loginRules: {
    admin_name: [
      { required: true, trigger: 'blur', message: '用户名不能为空' },
      { min: 3, max: 10, trigger: 'blur', message: '长度在 3 到 10 个字符' }
    ],
    admin_password: [
      { required: true, trigger: 'blur', message: '密码不能为空' },
      { min: 3, max: 10, trigger: 'blur', message: '长度在 3 到 10 个字符' }
    ]
    // code: [{ required: true, trigger: 'change', message: '验证码不能为空' }]
  },

  //Ⅰ级菜单验证
  setMenuRules: {
    menu_name: [
      { required: true, trigger: 'blur', message: 'Ⅰ级菜单不能为空' },
      { min: 2, max: 10, trigger: 'blur', message: '长度在 2 到 10 个字符' }
    ],
    menu_id: [
      { required: true, trigger: 'blur', message: 'Ⅰ级菜单ID不能为空' },
      { min: 1, max: 100, trigger: 'blur', message: '长度在 1 到 100 个字符' }
    ],
    menu_path: [
      { required: true, trigger: 'blur', message: 'Ⅰ级菜单路径不能为空' },
      { min: 3, max: 10, trigger: 'blur', message: '长度在 3 到 10 个字符' }
    ],
    menu_icon: [
      { required: true, trigger: 'blur', message: 'Ⅰ级菜单图标不能为空' },
      { min: 3, max: 20, trigger: 'blur', message: '长度在 3 到 20 个字符' }
    ]
  },

  //Ⅱ级菜单验证
  setSubmenuRules: {
    menu_id: [
      { required: true, trigger: 'blur', message: 'Ⅰ级菜单不能为空' },
      { min: 1, max: 10, trigger: 'blur', message: '长度在 2 到 10 个字符' }
    ],
    menu_name: [
      { required: true, trigger: 'blur', message: 'Ⅱ级菜单不能为空' },
      { min: 1, max: 100, trigger: 'blur', message: '长度在 1 到 100 个字符' }
    ],
    subMenuIdvalue: [
      { required: true, trigger: 'change', message: 'Ⅱ级菜单分组不能为空' },
      { min: 1, max: 50, trigger: 'change', message: '长度在 1 到 50 个字符' }
    ],
    menu_path: [
      { required: true, trigger: 'blur', message: 'Ⅱ级菜单路径不能为空' },
      { pattern: utils.letter.validateLowerCase(), trigger: 'blur', message: 'Ⅱ级菜单路径只能是小字母' },
      { min: 3, max: 10, trigger: 'blur', message: '长度在 3 到 10 个字符' }
    ]
  },

  //编辑菜单验证
  editMenuFormRules: {
    menu_id: [
      { required: true, trigger: 'blur', message: '菜单名字ID不能为空' },
      { min: 1, max: 100, trigger: 'blur', message: '长度在 1 到 100 个字符' }
    ],
    menu_name: [
      { required: true, trigger: 'blur', message: '菜单名字不能为空' },
      { min: 2, max: 20, trigger: 'blur', message: '长度在 2 到 20 个字符' }
    ],
  }
}
export default validate